package thread;

public class Test4 {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(()->{
            //while(!t.isInterrupted()){
            while (!Thread.currentThread().isInterrupted()){
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    //e.printStackTrace();
                    break;
                }
            }
        });
        t.start();
        Thread.sleep(2000);
        t.interrupt();
    }
}
